<div class="span9">
  <div class="thumbnail">
    <!-- breadcrumb -->
    <ul class="breadcrumb">
      <li><a href="{:U(GROUP_NAME . '/Index/index')}">用户管理</a> <span class="divider">/</span></li>
      <li><a href="{:U(GROUP_NAME . '/Index/user')}">用户列表</a> <span class="divider">/</span></li>
      <li class="active">配置用户角色</li>
    </ul>

    <table class="table">
      <caption>
        <h3>用户：{$user.username}　现有角色</h3>
      </caption>
      <thead>
        <tr>
          <th>编号</th>
          <th>名称</th>
          <th>操作</th>
        </tr>
      </thead>
      <tbody>
        <volist name="roleUser" id="ru">
          <tr>
            <td>{$ru.role_id}</td>
            <td>{$ru.name}</td>
            <td>
              <form action="{:U(GROUP_NAME . '/Rbac/delRoleUser')}" method="post">
                <input type="hidden" name="roleUser" value="{$ru.role_id}_{$user.p_id}">
                <input type="submit" class="btn btn-danger" value="删除">
              </form>
            </td>
          </tr>
        </volist>
      </tbody>
    </table>
  </div>
  <br>
  <div class="thumbnail">
    <h3 class="text-center">添加用户角色</h3>
    <form class="form-horizontal" role="form" method="post" action="{:U(GROUP_NAME . '/Rbac/modifyUserRole')}">
      <input type="hidden" name="p_id" value="{$user.u_id}">
      <!-- 所属角色 -->
      <div class="control-group" id="add-role-group">
        <!-- <label for="title" class="col-sm-2 control-label">所属角色</label> -->
        <div class="controls">
          <input type="button" class="btn" id="add-role" value="添加一个角色">
          <select class="form-control" id="select" name="role_id[]">
            <volist name="role" id="r">
              <option value="{$r.id}">{$r.name}({$r.remark})</option>
            </volist>
          </select>
        </div>
      </div>

      <div class="control-group" id="last">
        <br>
        <div class="controls">
          <!-- <a href="{:U(GROUP_NAME . '/Rbac/userRole', array('id' => $user['p_id']))}">取消添加</a> -->
          <button type="submit" class="btn btn-primary">确定添加</button>
        </div>
      </div>
    </form>
  </div>
</div>

<script>
  $(function () {
    $('#add-role').click(function () {
      var obj = $('#add-role-group').clone();
      obj.find('#add-role').remove();
      $('#last').before(obj);
    });
  });
</script>